package com.zhengxin.service.impl;

import java.io.Serializable;
import java.util.List;

import com.zhengxin.dao.IEmployeeDao;
import com.zhengxin.pojo.Employee;
import com.zhengxin.service.IEmployeeService;

public class EmployeeService implements IEmployeeService {

	private IEmployeeDao employeeDao;
	
	public IEmployeeDao getEmployeeDao() {
		return employeeDao;
	}

	public void setEmployeeDao(IEmployeeDao employeeDao) {
		this.employeeDao = employeeDao;
	}

	@Override
	public void save(Employee t) {
		employeeDao.save(t);
	}

	@Override
	public Employee findByid(Serializable id) {
		return employeeDao.findByid(id);
	}

	@Override
	public List<Employee> getAll() {
		List<Employee> list=employeeDao.getAll();
		
		return list;
	}

	@Override
	public void update(Employee t) {
		// TODO Auto-generated method stub
		employeeDao.update(t);
	}

	@Override
	public void delete(Serializable id) {
		// TODO Auto-generated method stub
		employeeDao.delete(id);
	}

	@Override
	public Employee login(Employee employee) {
		String hql="from Employee where name=? and password=?";
		// 调用dao查询方法
		List<Employee> list=employeeDao.getByCondition(hql, employee.getName(),employee.getPassword());
		//判断
		if(list != null && list.size()>0){
			return list.get(0);
		}
		//登录失败
		return null;
	}
}
